<?=$this->Html->css('form') ?>
<?=$this->Html->css('deal') ?>
<?php echo $this->Html->css('rateit'); ?>
<?php echo $this->Html->css('search'); ?>
<?php echo $this->Html->css('category'); ?>
<?php echo $this->Html->css('jquery.mCustomScrollbar'); ?>
<?php echo $this->Html->script('jquery.mCustomScrollbar'); ?>
<?php echo $this->Html->script('jquery.mousewheel.min'); ?>
<?php echo $this->Html->script('jquery.rateit.min'); ?>

<div class="form_wrapper">
    <div class="title">Purchased items</div>
        <?php
        $t = 0; $total = 0;
        foreach($deals as $deal) {
            $total += $deal['Deal']['price']; ?>
            <div class="drow" id="deal_<?=$deal['Deal']['id']?>">
                <div class="dleft">
                    <?=$html->image('posts/'.$deal['Product']['image'], array('class' => 'deal-picture'));?>
                </div>
                <div class="dmid">
                    <?= $html->link($deal['Product']['name'], '/products/view/'.$deal['Product']['id']); ?>
                    <p>Price: $<?=$deal['Deal']['price']?></p>
                    <p>Seller: <a href="<?=$this->webroot?>users/view/<?=$deal['User']['id']?>"><?=$deal['User']['name']?></a></p>
                </div>
            </div>
        <?php } ?>
    <div style="clear:both"></div>
    <div>Total price: $<?=$total ?></div>
    <div class="title" style="margin-bottom: 15px; margin-top:30px">Rate our product</div>
        <?php
        $t = 0;
        foreach($products as $product) { ?>
            <div class="catrow" style="float:left;width:100%">
                <div class="rowleft" style="width:22%">
                    <a href="<?=$this->webroot?>products/view/<?=$product['Product']['id']?>">
                        <img src="<?=$this->webroot?>img/posts/<?=$product['Product']['image']?>" style="width:200px;height:158px;margin:20px 0px"/>
                    </a>
                    <div class="rating" id="<?=$product['Product']['id']?>" style="margin-bottom:5px"></div>
                </div>
                <div class="rowright" style="width:68%">
                    <div class="ptitle"><span><?=substr($product['Product']['name'],0,60)?></span></div>
                    <div class="pinfo">
                        <ul class="pilt">
                            <li style="padding-top:0px;padding-bottom:0px">Manufacturer: <a href="<?=$product['Manufacturer']['url']?>"><?=$product['Manufacturer']['name']?></a></li>
                            <li style="padding-top:0px;padding-bottom:0px">Category: <?=$product['Category']['name']?></li>
                            <li style="height:100px;margin-top:5px;width:240%" class="scrollItem"><?=$product['Product']['description']?></li>
                        </ul>
                    </div>
                </div>
            </div>
        <?php } ?>
    </div>
    <div class="title" style="margin: 30px 30px">Shipping status</div>
    <div style="margin: 30px 30px">On the way</div>
</div>
<script>
$(document).ready(function(){
    $('.scrollItem').mCustomScrollbar();
    $('.rating').rateit({step: 1});
    $('.rating').bind('rated', function(event, value){
        $.ajax({
            type: 'POST',
            url: webroot + "ratings/rate/<?=$user['User']['id']?>/" + event.target.id + '/' + value,
            success: function() {
                $.jGrowl('Thank you for your feedback');
            }
        });
    });
});
</script>
